﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="File.aspx.cs" Inherits="PageEdit_File" %>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=GB2312">
<META CONTENT=VBScript>
<SCRIPT LANGUAGE=vbscript>
<!--
dim bolPreview

Sub selType_onchange
	if frmFile.selType.value = 0 then
		frmFile.txtFileUrl.style.display = "none"
		frmFile.filFileUp.style.display = ""
	else
		frmFile.filFileUp.style.display = "none"
		frmFile.txtFileUrl.style.display = ""
	end if
	Call ShowViewText()
End Sub

'显示预览文字
Sub ShowViewText()
	Call PasteHtml("<table border=0 width='100%' height='100%'><tr><td align='center'><font color='#C0C0C0' style=""font-size:9pt;font-family:宋体"">预览样式</font></td></tr></table>")
	bolPreview = False
End Sub

Sub window_onload
	Call ShowViewText()
End Sub

'预览文件HTML代码
Function FileHtmlView()
	On Error Resume Next
	dim p,s
	if frmFile.selType.value = 0 then
		p = frmFile.filFileUp.value
	else
		p = frmFile.txtFileUrl.value
	end if
	s = s &"<table border=0 width='100%' height='100%'><tr><td align='center'>"
	s = s &"<img border='0' src='../PageEdit/ICO/"& Mid(p,InStrRev(p,".") + 1,Len(p)) &".gif' width='16' height='16'> "
	s = s &"<a href='"& p &"' target='_blank'>"
	if Trim(frmFile.txtAlt.value) <> "" then
		s = s & frmFile.txtAlt.value
	else
		p1 = Replace(p,"/","\")
		s = s & Mid(p1,InStrRev(p1,"\") + 1,Len(p1))
	end if
	s = s &"</a>"
	s = s &"</td></tr></table>"
	FileHtmlView = s
End Function

'插入文件HTML代码
Function FileHtml()
	On Error Resume Next
	dim p,s
	if frmFile.selType.value = 0 then
		p = frmFile.filFileUp.value
	else
		p = frmFile.txtFileUrl.value
	end if
	s = s &"<img border='0' src='../PageEdit/ICO/"& Mid(p,InStrRev(p,".") + 1,Len(p)) &".gif' width='16' height='16'> "
	s = s &"<a href='"& p &"' target='_blank'>"
	if Trim(frmFile.txtAlt.value) <> "" then
		s = s & frmFile.txtAlt.value
	else
		p1 = Replace(p,"/","\")
		s = s & Mid(p1,InStrRev(p1,"\") + 1,Len(p1))
	end if
	s = s &"</a>"
	FileHtml = s
End Function

'点击预览按钮
Sub butPreview_onclick
	dim s
	if frmFile.selType.value = 0 then
		if frmFile.filFileUp.value = "" then
			msgbox "请选择一个文件！",16,"插入文件"
		else
			If UCase(Right(frmFile.filFileUp.value,4)) = ".XLS" Then
				If Len(frmFile.filFileUp.value) > 22 Then
					msgbox "当 Excel 的文件名超过18个字符时，用户可能无法通过点击正常下载该文件。建议您将该文件名缩短在18个字符以内。",16,"PageEdit"
				End If
			End If
			
			Call PasteHtml(FileHtmlView())
			bolPreview = True
			frmFile.txtFileName.value = frmFile.filFileUp.value
		end if
	else
		if len(frmFile.txtFileUrl.value) < 10 then
			msgbox "请输入文件的网上路径！",16,"插入文件"
		else
			Call PasteHtml(FileHtmlView())
			bolPreview = True
		end if
	end if
End Sub

'将HTML粘贴在编辑框内
Sub PasteHtml(byval s)
	On Error Resume Next
	ifrView.document.body.innerHtml = s
End Sub

Sub butSend_onclick
	if bolPreview = False then
		Call butPreview_onclick()
	else
		if frmFile.selType.value = 0 then
			frmFile.submit()
			frmFile.butSend.disabled = True
		else
			window.parent.PasteHtml(FileHtml())
		end if
	end if
End Sub

-->
</SCRIPT>
<TITLE>PageEdit - 插入文件</TITLE>
<style type="text/css">
<!--
body{font-size: 9pt}
td{font-size: 9pt}
select{font-size: 9pt}
input{font-size: 9pt}
A{text-decoration: none;}
A:hover{color: #FF0000; text-decoration: underline;}
-->
</style>
</HEAD>
<BODY bgcolor="#D4D0C8" topmargin="0" leftmargin="0" style="border:0" Scroll="no" onContextMenu="JavaScript:return false" OnDragStart="JavaScript:return false" OnScroll="JavaScript:return false">

<form enctype="multipart/form-data" id="frmFile" name="frmFile" action="File.aspx" method=post runat="server">
<table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolorlight="#C0C0C0" bordercolordark="#000000" bgcolor="#D4D0C8">
  <tr>
    <td valign="top" bordercolorlight="#808080" bordercolordark="#FFFFFF">
    <table border="0" width="100%" height="100%" cellspacing="2" cellpadding="2">
      <tr>
        <td bgcolor="#0742A7" colspan="2">
          <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td nowrap><font color="#FFFFFF">插入文件</font></td>
              <td align="right"><IMG onClick="javascript:window.parent.HiddenToolbarIframe()" onMouseOver="javascript:this.src='ButClose1.gif'" onMouseOut="javascript:this.src='ButClose0.gif'" SRC="ButClose0.gif" width="16" height="16"></td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td colspan="2" nowrap><SELECT name=selType size="1">
		<OPTION value=0>本机文件</OPTION>
		<OPTION value=1>网上连接</OPTION>
		</SELECT><INPUT type="file" id="filFileUp" name="filFileUp" style="width:290" RUNAT="server"><INPUT type="hidden" id=txtFileName name=txtFileName size=4><input type="text" name="txtFileUrl" value="http://" style="display:none;width:290">
        </td>
      </tr>
      <tr>
        <td><iframe id=ifrView MARGINWIDTH="0" MARGINHEIGHT="0" HSPACE="0" VSPACE="0" style="width:160;height:85"></iframe></td>
        <td>
			<table border="0">
			  <tr>
			    <td colspan="2"><INPUT type="button" value="预览样式" style="height:20" name="butPreview"></td>
			  </tr>
			  <tr>
			    <td colspan="2">
                  <table border="0" width="100%" cellspacing="0" cellpadding="0">
                    <tr>
                      <td bgcolor="#808080"><img border="0" src="Space.gif" width="1" height="1"></td>
                    </tr>
                    <tr>
                      <td bgcolor="#FFFFFF"><img border="0" src="Space.gif" width="1" height="1"></td>
                    </tr>
                  </table>
                </td>
			  </tr>
			  <tr>
			    <td nowrap>替换文字：</td>
			    <td nowrap><input type="text" name="txtAlt" size="20"></td>
			  </tr>
			  <tr>
			    <td colspan="2">
                  <table border="0" width="100%" cellspacing="0" cellpadding="0">
                    <tr>
                      <td bgcolor="#808080"><img border="0" src="Space.gif" width="1" height="1"></td>
                    </tr>
                    <tr>
                      <td bgcolor="#FFFFFF"><img border="0" src="Space.gif" width="1" height="1"></td>
                    </tr>
                  </table>
                </td>
			  </tr>
			  <tr>
			    <td nowrap colspan="2" align="right"><input type="button" value="　确定　" name="butSend"><input type="button" value="　取消　" onClick="javascript:window.parent.HiddenToolbarIframe();frmFile.butSend.disabled=''"></td>
			  </tr>
			</table>
        </td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</form>

</BODY>
</HTML>
